﻿package com.mini.framework.bi.bpull.chart;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.mini.framework.bi.bpull.model.TBody;
import com.mini.framework.bi.bpull.model.TFoot;

/**
 * 
 * @author lishsh.
 *
 */
public class TableChart {
	
	private String curPage;//当前页.
	
	private String totalPage;//总页数.
	
	private String pageItem;//一页数.
	
	private String tip;//提示.
	
	private String by;//排序.
	
	private String order;//升降序.
	
	private List<String> thead;//表头.
	
	private List<String> total;//总计.
	
	private List<TBody> tbody;//表中间数据.
	
	private List<TFoot> tfoot;

	public String getCurPage() {
		return curPage;
	}

	public void setCurPage(String curPage) {
		this.curPage = curPage;
	}

	public String getTotalPage() {
		return totalPage;
	}

	public void setTotalPage(String totalPage) {
		this.totalPage = totalPage;
	}

	public String getPageItem() {
		return pageItem;
	}

	public void setPageItem(String pageItem) {
		this.pageItem = pageItem;
	}

	public String getTip() {
		return tip;
	}

	public void setTip(String tip) {
		this.tip = tip;
	}

	public String getBy() {
		return by;
	}

	public void setBy(String by) {
		this.by = by;
	}

	public String getOrder() {
		return order;
	}

	public void setOrder(String order) {
		this.order = order;
	}

	public List<String> getThead() {
		return thead;
	}

	public void setThead(List<String> thead) {
		this.thead = thead;
	}

	public List<String> getTotal() {
		return total;
	}

	public void setTotal(List<String> total) {
		this.total = total;
	}

	public List<TBody> getTbody() {
		return tbody;
	}

	public void setTbody(List<TBody> tbody) {
		this.tbody = tbody;
	}
	
	
	
	public List<TFoot> getTfoot() {
		return tfoot;
	}

	public void setTfoot(List<TFoot> tfoot) {
		this.tfoot = tfoot;
	}

	/******************************/
	public void setThead(String[] thead){
		this.thead = Arrays.asList(thead);
	}
	
	public void setTotal(String[] total){
		this.total = Arrays.asList(total);
	}
	
	
	
	public Map<String,Object> getJson(){
		Map<String,Object> json = new HashMap<String,Object>();
		json.put("curPage", this.getCurPage());
		json.put("totalPage", this.getTotalPage());
		json.put("pageItem", this.getPageItem());
		json.put("tip", this.getTip());
		json.put("by", this.getBy());
		json.put("order", this.getOrder());
		json.put("thead", this.getThead());
		json.put("total", this.getTotal());
		json.put("tbody", this.getTbody());
		json.put("tfoot", this.getTfoot());
		return json;
	}
	
	
	public Map<String,Object> demo(){
		TableChart table = new TableChart();
		
		table.setCurPage("1");
		table.setTotalPage("1");
		table.setPageItem("20");
		table.setTip("");
		table.setBy("pv_count");
		table.setOrder("desc");
		
		String[] thead = new String[]{"area","pv_count","visitor_count","ip_count","visit_single_ratio","average_visit_time","finished_transform_count","transform_ratio"};
		table.setThead(thead);
		String[] total = new String[]{"","7912","562","567","28.49%","00:07:35","6","0.66%"};
		table.setTotal(total);
		List<TBody> tbody = new ArrayList<TBody>();
		for(int i=0;i<10;i++){
			TBody datai= new TBody();
			datai.setId(Integer.toString(i));
			datai.setName("data"+i);
			datai.setPic("");
			datai.setUnique(Integer.toString(i));
			List<String> data = new ArrayList<String>();
			data.add("42");
			data.add("42");
			data.add("42");
			data.add("42");
			data.add("42");
			data.add("42");
			data.add("42");
			data.add("42");
			datai.setData(data);
			tbody.add(datai);
		}
		table.setTbody(tbody);
		return table.getJson();
	}
	

}
